<?php



/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Gmap
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
 
class Gmap_Form_Coordinate extends Engine_Form
{
  public $_error = array();

  public function init()
  {
    $this
      ->addPrefixPath('Fields_Form_Element', APPLICATION_PATH . '/application/modules/Fields/Form/Element', 'element');
    
    $this->setTitle('Edit Gmap Coordinate')
      ->setDescription('You can change the coordinate of this gmap by entering its latitude and longitude, or simple drag the marker on the map to the desired location.')
      ->setAttrib('name', 'gmaps_coordinate')
      ;

    $this->addElement('Text', 'formatted_address', array(
      'label' => 'Standardized Address',
     'description' => 'Formatted by Google Geo Coding Service',
      'allowEmpty' => false,
      'required' => true,
      'validators' => array(
        array('NotEmpty', true),
        array('StringLength', false, array(1, 128)),
      ),
    ));       
    $this->formatted_address->getDecorator("Description")->setOption("placement", "append"); 
    
    $this->addElement('Heading','heading', array(
      'value' => 'Location Details'
    ));
    $this->heading->removeDecorator('Label')
          ->removeDecorator('HtmlTag')
          ->getDecorator('HtmlTag2')->setOption('class', 'form-wrapper-heading');
    
    $this->addElement('Text', 'street_address', array(
      'label' => 'Street Address',
      'validators' => array(
        array('StringLength', false, array(1, 128)),
      ),
    ));       
    $this->street_address->getDecorator("Description")->setOption("placement", "append"); 
    
    $this->addElement('Text', 'city', array(
      'label' => 'City',
      'validators' => array(
        array('StringLength', false, array(1, 64)),
      ),
    ));       
    $this->city->getDecorator("Description")->setOption("placement", "append"); 
    
    $this->addElement('Text', 'state', array(
      'label' => 'State',
      'validators' => array(
        array('StringLength', false, array(1, 64)),
      ),
    ));       
    $this->state->getDecorator("Description")->setOption("placement", "append");     
    
    $this->addElement('Text', 'zip', array(
      'label' => 'Zip Code',
      'validators' => array(
        array('StringLength', false, array(1, 64)),
      ),
    ));       
    $this->state->getDecorator("Description")->setOption("placement", "append");     
    
    $this->addElement('Country', 'country', array(
      'label' => 'Country',
      'validators' => array(
        array('StringLength', false, array(1, 64)),
      ),
    ));       
    $this->state->getDecorator("Description")->setOption("placement", "append");      
    
    $this->addElement('Heading','heading2', array(
      'value' => 'Location Geocode'
    ));
    $this->heading2->removeDecorator('Label')
          ->removeDecorator('HtmlTag')
          ->getDecorator('HtmlTag2')->setOption('class', 'form-wrapper-heading');    
      
    $this->addElement('Text', 'lat', array(
      'label' => 'Latitude',
      'description' => 'Enter decimal point from -90 to 90',
      'allowEmpty' => false,
      'required' => true,
      'validators' => array(
        array('NotEmpty', true),
        new Zend_Validate_Float(),
        new Zend_Validate_Between(-90,90)
      ),
    ));
    $this->lat->getDecorator("Description")->setOption("placement", "append");
            
    $this->addElement('Text', 'lng', array(
      'label' => 'Longitude',
      'description' => 'Enter decimal point from -180 to 180',
      'allowEmpty' => false,
      'required' => true,
      'validators' => array(
        array('NotEmpty', true),
        new Zend_Validate_Float(),
        new Zend_Validate_Between(-180,180)
      ),
    ));
    $this->lng->getDecorator("Description")->setOption("placement", "append");
    
    // Buttons
    $this->addElement('Button', 'submit', array(
      'label' => 'Save Changes',
      'type' => 'submit',
      'ignore' => true,
      'decorators' => array('ViewHelper')
    ));

    $this->addElement('Cancel', 'cancel', array(
      'label' => 'cancel',
      'link' => true,
      'prependText' => ' or ',
      'decorators' => array(
        'ViewHelper'
      )
    ));
    
    $this->addDisplayGroup(array('submit', 'cancel'), 'buttons');
    $button_group = $this->getDisplayGroup('buttons');
    $button_group->addDecorator('DivDivDivWrapper');    

    
  }

}